﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using AppLab.Web;
using AppLab.Web.Services;
using System.ServiceModel.DomainServices.Client;

namespace AppLab.Views.MobileBasicInfo
{
    public partial class Adaptation : ChildWindow
    {
        private FlowContext flow = new FlowContext();
        private MoblieAdaptationInfoData wapAdaptation = new MoblieAdaptationInfoData();
        private MoblieAdaptationInfoData clientAdaptation = new MoblieAdaptationInfoData();

        public Adaptation()
        {
            InitializeComponent();
            this.Title = ApplicationStrings.AdaptationWindowTitle;
        }

        public Adaptation(string mobileType, int mobileID)
        {
            InitializeComponent();
            this.Title = ApplicationStrings.AdaptationWindowTitle;
            this.tbMobile.Text = mobileType + ApplicationStrings.AdaptationStatusTip;
            BindAdaptationStatus();
            BindPartners();
        }

        #region 两种状态

        private void GetAdaptation(int mobileID)
        {
            //var query = flow.GetAdaptationInfoQuery(mobileID);
            //LoadOperation loadOp = flow.Load(query);
            //loadOp.Completed += new EventHandler(loadOp_Completed);

            //flow.geta(submitData.Mobile, op =>
            //{
            //    if (!op.HasError)
            //        submitData.PackageOSPattern = (op.Value == null) ? string.Empty : op.Value.OSName.Replace(".", "");
            //}, null);

        }

        //void loadOp_Completed(object sender, EventArgs e)
        //{
            
        //}
        
        #endregion

        #region 适配状态

        private void BindAdaptationStatus()
        {
            var queryStatus = flow.GetAdaptationStatusQuery();
            var loadStatus = flow.Load(queryStatus);
            this.cbAdaptationStatus.ItemsSource = loadStatus.Entities;
            this.cbAdaptationStatus.DisplayMemberPath = "AdaptationStatusName";
        }

        #endregion

        #region 开发商

        private void BindPartners()
        {
            var queryPartners = flow.GetPartnersQuery();
            var loadPartners = flow.Load(queryPartners);
            this.cbPartners.ItemsSource = loadPartners.Entities;
            this.cbPartners.DisplayMemberPath = "PartnerName";
        }

        #endregion

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void rbWap_Checked(object sender, RoutedEventArgs e)
        {

        }

        private void rbClient_Checked(object sender, RoutedEventArgs e)
        {

        }
    }
}

